<template>
	<view class="customerDetails">
		<view class="touxian">
			<image :src="datas.avatar_url" mode="scaleToFill" style="width: 120rpx; height: 120rpx;"></image>
			<text>{{datas.user_name}}</text>
			<text class="genderAge"> <text v-if="datas.user_sex == 1">男</text> <text v-else>女</text> <text>{{datas.user_age}} 岁</text>
			</text>
		</view>
		<view class="appointment">
			<text class="number">预约记录( <text>{{list.length}}</text> )</text>
			<view class="times" v-for="(item,index) in list">
				<text>服务时间：<text>{{item.create_time}}</text> </text>
				<text>服务项目：<text>{{item.items_title}}</text> </text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(options) {
			this.datas = JSON.parse(decodeURIComponent(options.datas));
			this.getCustomerDetail(this.datas.openid);
		},
		data() {
			return {
				datas: null,
				list: null,
			};
		},
		methods: {
			async getCustomerDetail(openid) {
				let service_id = this.$store.state.userinfo.id;
				let res = await this.$myrequest({
					url: `Service/getCustomerDetail?openid=${openid}&service_id=${service_id}`
				});
				this.list = res.data.data;
			}
		},
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
	}

	.customerDetails {
		width: 100%;
		height: 100%;
		padding: 0 30rpx;
		background-color: #F1F3F4;
	}

	.touxian {
		padding-top: 60rpx;
		display: flex;
		flex-wrap: wrap;

		image {
			margin-left: 50%;
			transform: translateX(-50%);
			border-radius: 50%;
		}

		>text {
			width: 100%;

			&:first-of-type {
				display: inline-block;
				margin-top: 31rpx;
				color: #000000;
				font-size: 30rpx;
				text-align: center;
			}

			&:nth-of-type(2) {
				color: #999999;
				@include shuipingchuijuzhong;

				text {
					margin-left: 20rpx;
				}
			}
		}
	}

	.appointment {
		margin-top: 120rpx;
		position: relative;
		border-radius: 20rpx;
		padding: 0 30rpx;
		background-color: #FFFFFF;

		.number {
			position: absolute;
			top: -75rpx;
			left: 30rpx;
			@include xiaoludian(-30rpx);
		}

		.times {
			padding: 30rpx 0;

			&:not(:last-of-type) {
				border-bottom: 2rpx solid #DBDBDB;
			}

			>text {
				display: inline-block;
				width: 100%;
				font-size: 28rpx;
				color: #000000;

				text {
					color: #999999;
				}
			}
		}
	}
</style>
